//
//  UIBarButtonItem+Category.swift
//  ZMWWeibo
//
//  Created by 张美文 on 16/1/6.
//  Copyright © 2016年 walter. All rights reserved.
//

import UIKit

extension UIBarButtonItem{
    //如果在func前面加上class，就相当于OC中的+
    class func createBarButtonItem(imageName:String, target:AnyObject?, action:Selector) -> UIBarButtonItem
    {
        //
        let btn = UIButton()
        btn.setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        btn.sizeToFit()
        btn.setImage(UIImage(named: imageName + "_highlighted"), forState: UIControlState.Highlighted)
        btn.addTarget(target, action: action, forControlEvents: UIControlEvents.TouchUpInside)
        return UIBarButtonItem(customView: btn)
    }
}
